#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>

using namespace std;

const int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
int ans = 0;
int N;

bool check(vector<vector<char>> &mat, int i, int j)
{
    if (mat[i][j] != '.')
        return false;
    for (int k = 0; k < 4; k++)
    {
        int x = i + dir[k][0];
        int y = j + dir[k][1];
        while(true)
        {
            if(x < 0 || x >= N || y < 0 || y >= N || mat[x][y] == 'X')
                break;
            else if (mat[x][y] == 'o')
                return false;
            x += dir[k][0];
            y += dir[k][1];
        }
    }
    return true;
}
void dfs(vector<vector<char>> &mat, int cnt)
{
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            if (check(mat, i, j))
            {
                mat[i][j] = 'o';
                dfs(mat, cnt+1);
                mat[i][j] = '.';
            }
    ans = max(ans, cnt);
}

int main()
{
    while (cin >> N && N)
    {
        ans = 0;
        vector<vector<char>> mat(N, vector<char>(N));

        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                cin >> mat[i][j];

        dfs(mat, 0);

        cout << ans << endl;
    }
    return 0;
}